home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / Symbol.z / Symbol
Encoding:
Text File  |  2002-10-03  |  2.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. SSSSyyyymmmmbbbboooollll((((3333))))                                                            SSSSyyyymmmmbbbboooollll((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Symbol - manipulate Perl symbols and their names
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use Symbol;
  13.  
  14.          $sym = gensym;
  15.          open($sym, "filename");
  16.          $_ = <$sym>;
  17.          # etc.
  18.  
  19.          ungensym $sym;      # no effect
  20.  
  21.          print qualify("x"), "\n";              # "Test::x"
  22.          print qualify("x", "FOO"), "\n"        # "FOO::x"
  23.          print qualify("BAR::x"), "\n";         # "BAR::x"
  24.          print qualify("BAR::x", "FOO"), "\n";  # "BAR::x"
  25.          print qualify("STDOUT", "FOO"), "\n";  # "main::STDOUT" (global)
  26.          print qualify(\*x), "\n";              # returns \*x
  27.          print qualify(\*x, "FOO"), "\n";       # returns \*x
  28.  
  29.          use strict refs;
  30.          print { qualify_to_ref $fh } "foo!\n";
  31.          $ref = qualify_to_ref $name, $pkg;
  32.  
  33.          use Symbol qw(delete_package);
  34.          delete_package('Foo::Bar');
  35.          print "deleted\n" unless exists $Foo::{'Bar::'};
  36.  
  37.  
  38. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  39.      Symbol::gensym creates an anonymous glob and returns a reference to it.
  40.      Such a glob reference can be used as a file or directory handle.
  41.  
  42.      For backward compatibility with older implementations that didn't support
  43.      anonymous globs, Symbol::ungensym is also provided.  But it doesn't do
  44.      anything.
  45.  
  46.      Symbol::qualify turns unqualified symbol names into qualified variable
  47.      names (e.g. "myvar" -> "MyPackage::myvar").  If it is given a second
  48.      parameter, qualify uses it as the default package; otherwise, it uses the
  49.      package of its caller.  Regardless, global variable names (e.g. "STDOUT",
  50.      "ENV", "SIG") are always qualfied with "main::".
  51.  
  52.      Qualification applies only to symbol names (strings).  References are
  53.      left unchanged under the assumption that they are glob references, which
  54.      are qualified by their nature.
  55.  
  56.      Symbol::qualify_to_ref is just like Symbol::qualify except that it
  57.      returns a glob ref rather than a symbol name, so you can use the result
  58.      even if use strict 'refs' is in effect.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SSSSyyyymmmmbbbboooollll((((3333))))                                                            SSSSyyyymmmmbbbboooollll((((3333))))
  71.  
  72.  
  73.  
  74.      Symbol::delete_package wipes out a whole package namespace.  Note this
  75.      routine is not exported by default--you may want to import it explicitly.
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.